package com.tianxin.workbao.workBao.holder;

import android.content.Context;

import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;

import com.tianxin.workbao.workBao.R;
import com.tianxin.workbao.workBao.adapter.SelectCoalAdapter;
import com.tianxin.workbao.workBao.listener.MyPopupWindowListener;

/**
 * Created by hacker on 2017/7/2.
 */

public class SelectCoalHolder {
    private Context mContext;
    private View mContentView;
    private MyPopupWindowListener myPopupWindowListener;
    private SelectCoalAdapter mAdapter;
    private RecyclerView mRecyclerView;


    public SelectCoalHolder(Context context, MyPopupWindowListener listener, SelectCoalAdapter adapter) {
        this.mContext = context;
        this.mContentView = LayoutInflater.from(mContext).inflate(R.layout.my_popup_window_view, null);
        this.myPopupWindowListener = listener;
        this.mAdapter = adapter;
        initView();
    }

    private void initView() {
        mRecyclerView = (RecyclerView) mContentView.findViewById(R.id.recyclerView);
        mRecyclerView.setAdapter(mAdapter);
        //设置Item增加、移除动画
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        //设置布局管理器
        int spanCount = 3;
        GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, spanCount);
        mRecyclerView.setLayoutManager(gridLayoutManager);
    }


    public View getContentView() {
        return mContentView;
    }

    public SelectCoalAdapter getAdapter() {
        return mAdapter;
    }

}
